import 'package:baselib/utils/color_base_util.dart';
import 'package:baselib/utils/image_util.dart';
import 'package:baselib/utils/px_base_util.dart';
import 'package:baselib/utils/string_base_util.dart';
import 'package:baselib/widgets/gradient_card_view.dart';
import 'package:flutter/material.dart';
import 'package:framelib/utils/color_util.dart';
import 'package:framelib/utils/drawable_util.dart';
import 'package:framelib/utils/px_util.dart';
import 'package:framelib/utils/string_util.dart';

import 'comm_widget_manager.dart';

class RoomOtherInfoGradientDialog extends Dialog {

  String icon;
  String name;
  int vipFlag;
  bool isFeMale;
  int userId;
  bool isUpMick;
  bool isForbidden;
  bool isTouchOutSideDissmiss;
  bool isTouchKeyBackDissmiss;
  bool isFollow;

  Function followTap;
  Function chatTap;
  Function toHomeTap;
  Function giftsTap;

  Function mickTap;
  Function voiceTap;
  Function blacklistTap;
  Function adminTap;
  Function kickoutTap;



  RoomOtherInfoGradientDialog({
    Key key,
    this.icon,
    this.name,
    this.vipFlag,
    this.isFeMale,
    this.userId,
    this.isUpMick,
    this.isForbidden,
    this.isFollow,

    this.followTap,
    this.chatTap,
    this.toHomeTap,
    this.giftsTap,

    this.mickTap,
    this.voiceTap,
    this.blacklistTap,
    this.adminTap,
    this.kickoutTap,

    this.isTouchOutSideDissmiss = true,
    this.isTouchKeyBackDissmiss = true,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return WillPopScope(
      onWillPop: () {
        if (isTouchKeyBackDissmiss) {
          Navigator.of(context).pop();
        }
      },
      child: GestureDetector(
        onTap: () {
          if (isTouchOutSideDissmiss) {
            Navigator.of(context).pop();
          }
        },
        child: new Material(
          type: MaterialType.transparency,
          child: new Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              GestureDetector(
                onTap: () {},
                child: GradientCardView(
                  elevation: PxBaseUtil().px_0,
                  margin: EdgeInsets.only(
                    left: PxBaseUtil().px_30,
                    right: PxBaseUtil().px_30,
                  ),
                  padding: EdgeInsets.only(),
                  borderRadius: BorderRadius.circular(PxBaseUtil().px_20),
                  child: Container(
                    decoration: BoxDecoration(
                      borderRadius: BorderRadius.circular(PxBaseUtil().px_20),
                      color: ColorBaseUtil().color_2F4072,
                    ),
                    padding: EdgeInsets.only(
                      left: PxBaseUtil().px_35,
                      right: PxBaseUtil().px_35,
                      top: PxBaseUtil().px_30,
                      bottom: PxBaseUtil().px_30,
                    ),
                    child: Column(
                      mainAxisSize: MainAxisSize.min,
                      crossAxisAlignment: CrossAxisAlignment.center,
                      children: [
                          //头像
                        CommWidgetManager.buildCicleImagWidget(
                          icon ?? '',
                          placeholder:
                          DrawableUtil.instance.icon_default_head,
                          width: PxUtil.instance.px_80,
                          height: PxUtil.instance.px_80,
                          roundRadius: PxUtil.instance.px_40,
                          backgroundColor: ColorUtil.instance.color_f2f2f2,
                          padding: EdgeInsets.only(),
                          margin: EdgeInsets.only(),
                        ),
                        SizedBox(height: PxUtil.instance.px_16,),
                        //名称、性别、等级
                        Row(
                          mainAxisAlignment: MainAxisAlignment.center,
                          children: [
                            Container(
                              child: Text(
                                '${name??'${StringUtil.instance.unknow}'}',
                                style: TextStyle(
                                  color: ColorUtil.instance.color_white,
                                  fontSize: PxUtil.instance.px_13,
                                  fontWeight: FontWeight.w500
                                ),
                              ),
                            ),
                            SizedBox(width: PxUtil.instance.px_9,),
                            ImagesUtil.loadAssetImage(
                              (isFeMale??false)?DrawableUtil.instance.icon_sex_female:
                              DrawableUtil.instance.icon_sex_male,
                              width: PxUtil.instance.px_14,
                              fit: BoxFit.fitWidth
                            ),
                            SizedBox(width: PxUtil.instance.px_9,),
                            GradientCardView(
                              elevation: PxUtil.instance.px_0,
                              alignment: Alignment.center,
                              margin: EdgeInsets.only(),
                              padding: EdgeInsets.only(),
                              borderRadius: BorderRadius.circular(PxUtil.instance.px_2),
                              child: Container(
                                padding: EdgeInsets.only(
                                  left: PxUtil.instance.px_5,
                                  right: PxUtil.instance.px_5,
                                  top: PxUtil.instance.px_2,
                                  bottom: PxUtil.instance.px_2,
                                ),
                                child: Text(
                                  'Lv${vipFlag??0}',
                                  style: TextStyle(
                                      fontSize: PxUtil.instance.px_9,
                                      fontWeight: FontWeight.bold,
                                      color: ColorUtil.instance.color_white
                                  ),
                                ),
                              ),
                            )
                          ],
                        ),
                        SizedBox(height: PxUtil.instance.px_10,),
                        //ID
                        Container(
                          child: Text(
                            '${StringUtil.instance.ID}：${userId??0}',
                            style: TextStyle(
                                color: ColorUtil.instance.color_cacaca,
                                fontSize: PxUtil.instance.px_10,
                            ),
                          ),
                        ),
                        SizedBox(height: PxUtil.instance.px_22,),
                        //关注、聊天、主页、礼物
                        Container(
                          child: Row(
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                            children: [
                              Expanded(child: Center(
                                child: GestureDetector(
                                  onTap: ()=>(followTap==null?(){}:followTap()),
                                  child: ImagesUtil.loadAssetImage(
                                      DrawableUtil.instance.icon_room_other_info_follow_white,
                                      width: PxUtil.instance.px_26,
                                    color: (isFollow??false)?Colors.blue:Colors.white60

                                  ),
                                ),
                              )),
                              Expanded(child: Center(
                                child: GestureDetector(
                                    onTap: ()=>(chatTap==null?(){}:chatTap()),
                                    child: ImagesUtil.loadAssetImage(
                                        DrawableUtil.instance.icon_room_other_info_chat_white,
                                        width: PxUtil.instance.px_26
                                    )
                                ),
                              )),
                              Expanded(child: Center(
                                child: GestureDetector(
                                    onTap: ()=>(toHomeTap==null?(){}:toHomeTap()),
                                    child: ImagesUtil.loadAssetImage(
                                        DrawableUtil.instance.icon_room_other_info_home_white,
                                        width: PxUtil.instance.px_26
                                    )
                                ),
                              )),
                              Expanded(child: Center(
                                child: GestureDetector(
                                    onTap: ()=>(giftsTap==null?(){}:giftsTap()),
                                    child: ImagesUtil.loadAssetImage(
                                        DrawableUtil.instance.icon_room_gifts,
                                        width: PxUtil.instance.px_26
                                    )
                                ),
                              ),)
                            ],
                          ),
                        ),
                        SizedBox(height: PxUtil.instance.px_22,),
                        //下麦、进入主页
                        Container(
                          child: Row(
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                            children: [
                              Expanded(child: Center(
                                child: GestureDetector(
                                  onTap: ()=>(mickTap==null?(){}:mickTap()),
                                  child: ImagesUtil.loadAssetImage(
                                      (isUpMick??false)?
                                      DrawableUtil.instance.icon_room_other_info_down_mick:
                                      DrawableUtil.instance.icon_room_other_info_up_mick,
                                      width: PxUtil.instance.px_36
                                  ),
                                ),
                              )),
                              (!(isUpMick??false))?SizedBox(width: 0,height: 0,):
                              Expanded(child: Center(
                                child: GestureDetector(
                                    onTap: ()=>(voiceTap==null?(){}:voiceTap()),
                                    child: ImagesUtil.loadAssetImage(
                                        (isForbidden??false)?
                                        DrawableUtil.instance.icon_room_other_info_voice:
                                        DrawableUtil.instance.icon_room_voice_speak_close,
                                        width: PxUtil.instance.px_36
                                    )
                                ),
                              )),
                              Expanded(child: Center(
                                child: GestureDetector(
                                    onTap: ()=>(blacklistTap==null?(){}:blacklistTap()),
                                    child: ImagesUtil.loadAssetImage(
                                        DrawableUtil.instance.icon_room_other_info_add_blacklist,
                                        width: PxUtil.instance.px_36
                                    )
                                ),
                              )),
                              Expanded(child: Center(
                                child: GestureDetector(
                                    onTap: ()=>(adminTap==null?(){}:adminTap()),
                                    child: ImagesUtil.loadAssetImage(
                                        DrawableUtil.instance.icon_room_other_info_add_admin,
                                        width: PxUtil.instance.px_36
                                    )
                                ),
                              )),
                              Expanded(child: Center(
                                child: GestureDetector(
                                    onTap: ()=>(kickoutTap==null?(){}:kickoutTap()),
                                    child: ImagesUtil.loadAssetImage(
                                        DrawableUtil.instance.icon_room_other_info_kickout,
                                        width: PxUtil.instance.px_36
                                    )
                                ),
                              ),)
                            ],
                          ),
                        )
                      ],
                    ),
                  ),
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
